<template>
  <el-form :model="formData" label-width="130px" ref="form" v-loading="loading" class="pr-1">
    <el-form-item prop="ids"> </el-form-item>
    <div class="formrow">
      <el-form-item prop="flow_code" label="选择工艺流程:" required>
        <input type="text" :value="formData.flow_code" disabled />
      </el-form-item>
      <el-button class="confirmBtn" type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>

    </div>
    <processflow @send-code="getCode" :ids="props.ids"></processflow>
  </el-form>
</template>

<script lang="ts">
import { defineComponent } from 'vue';

export default defineComponent({
  name: 'proCreate',
});
</script>

<script lang="ts" setup>
import { computed, onMounted, ref, defineProps } from 'vue'
import { useCreate } from '/admin/composables/curd/useCreate'
import { useShow } from '/admin/composables/curd/useShow'
import processflow from './processflow.vue';

const props = defineProps({
  primary: String ,
  api: String,
  ids: Array,
})

const sendApi = 'production/order/bindflow'

const { formData, form, loading, submitForm, close } = useCreate(sendApi, props.primary)
formData.value.ids = props.ids
console.log(formData)

if (props.primary) {
  useShow(props.api, props.primary, formData)
}

const emit = defineEmits(['close'])

const getCode = data => {
  console.log(data)
  formData.value.flow_code = data.pflcode
  // formData.value.flow_name = data.processname
}

onMounted(() => {
  close(() => emit('close'))
})
</script>

<style>
.formrow {
  width: 90%;
  display: flex;
  justify-content: space-between;
  /* align-items: center; */
  /* border: 1px solid #000; */
}
</style>
